<?php


class bTrain{
	private $category;
	private $contents = Array();
	public function __construct(bcategory $cat){
		if (!$cat->inTrainning())
			throw new Exception ("A categoria referida nao foi preparada para treinamento:{$cat->getType()}\n");
		$this->category = $cat;
	}
	public function Exec( ){
		// execute the train based on a content from contents array
			foreach ( $this->contents as $content){
				$words = split(' ',preg_replace(FILTER_EXPRESSION, " ",$content));
				foreach ($words as $word){
					if (strlen($word) <=IGNOREWORDEQUALSORLESSTHEN || $word=="")
						continue;
					$this->category->setWord($word,1);
				}
			}
			$this->category->calculate( count($this->contents));
			$this->category->Save();
	}
	public function addContent($content){
		array_push($this->contents,$content );
	}
	public function addContentbyDir($dir){
		//when I use this $dir indicate a directory where I can find documents and will use this documents contents to train
	}
	public function addContentbyUrl($url){
		// inform 
	}
	private function saveConfig(){
		// this function create a file categoryName.train to get hability to repeat the train.
	}
	
}
